//
//  ViewController.m
//  BookTest1
//
//  Created by IOS3 on 2018/10/31.
//  Copyright © 2018 IOS3. All rights reserved.
//

#import "ViewController.h"
#import "TestCorTextView1.h"
#import "TestCoreTextView2.h"
#import "CTDisplayView.h"
#import "CoreTextData.h"
#import "CTFrameParser.h"
#import "CTFrameParserConfig.h"
#import "TestCoreTextView_03.h"
#import "test3/TestCT004.h"


@interface ViewController ()

@property (nonatomic, strong) NSMutableString *bookMarkup;

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self test003];

}




- (void)test003 {
    UIView *view = [[TestCT004 alloc] init];
    view.frame = CGRectMake(0, 100, 400, 500);
    view.backgroundColor = [UIColor colorWithRed:.8f green:0.9f blue:0.9f alpha:1.f];
    [self.view addSubview:view];
}







- (void)test002 {
    UIView *view = [[TestCoreTextView_03 alloc] init];
    view.frame = CGRectMake(0, 100, 400, 500);
    view.backgroundColor = [UIColor colorWithRed:.8f green:0.9f blue:0.9f alpha:1.f];
    [self.view addSubview:view];
}




- (void)test001 {
//    TestCorTextView1 *view = [[TestCorTextView1 alloc] init];
//    view.frame = CGRectMake(0, 100, 300, 100);
//    view.backgroundColor = UIColor.grayColor;
//    [self.view addSubview:view];

//    TestCoreTextView2 *view = [[TestCoreTextView2 alloc] init];
//    view.backgroundColor = UIColor.whiteColor;
//    view.frame = CGRectMake(0, 44, UIScreen.mainScreen.bounds.size.width, UIScreen.mainScreen.bounds.size.height - 44);
//    [self.view addSubview:view];
    
    CTDisplayView *view = [[CTDisplayView alloc] init];
    view.frame = CGRectMake(0, 44, UIScreen.mainScreen.bounds.size.width, UIScreen.mainScreen.bounds.size.height - 44);
    view.backgroundColor = UIColor.whiteColor;
    
    CTFrameParserConfig *config = [[CTFrameParserConfig alloc] init];
    config.width = view.frame.size.width;
    config.textColor = UIColor.redColor;
    NSString *content =
    @" 对于上面的例子，我们给 CTFrameParser 增加了一个将 NSString 转 "
    " 换为 CoreTextData 的方法。"
    " 但这样的实现方式有很多局限性，因为整个内容虽然可以定制字体 "
    " 大小，颜色，行高等信息，但是却不能支持定制内容中的某一部分。"
    " 例如，如果我们只想让内容的前三个字显示成红色，而其它文字显 "
    " 示成黑色，那么就办不到了。"
    "\n\n"
    " 解决的办法很简单，我们让`CTFrameParser`支持接受 "
    "NSAttributeString 作为参数，然后在 NSAttributeString 中设置好 "
    " 我们想要的信息。";
    
    CoreTextData *data = [CTFrameParser parserContent:content config:config];
    view.data = data;
    CGRect frame = view.frame;
    frame.size.height = data.height;
    view.frame = frame;
    view.backgroundColor = UIColor.yellowColor;
    
    [self.view addSubview:view];
}


@end
